#ifndef ETHERNET_H
#define ETHERNET_H

#include "adc.h"
#include <QtNetwork>
#include <QThread>

class Ethernet : public QThread
{
	Q_OBJECT
	
	public:
	  Ethernet();
	  
	  bool isConnected();
	  
	  void setPhysVals(double,double,double);
	  double getForward();
	  double getLateral();
	  double getSpin();
	  double getDepth();
	  int getup(int);
	  
	  int getServo();
	  
	  void writeUdp();
	  void writeMotor();
    void sendConnect();	  
    
    bool hasDatagrams();
    
    void setMotor(int, double d1, double d2, double d3);
    
    bool getImuControl();
    
    void checkPendingDatagrams();
    
  private slots:
    void readPendingDatagrams();
	  
	private:
    void checkAlive();
    
    int timeAck;
    
    QUdpSocket *udpSocket;
    
    quint16 blockSize;
    
    QHostAddress serverHost;
           
    bool connected;
    
    double data1,data2,data3;
    
    double joyLat,
           joyFor,
           joySpin,
           depth;
           
    double scv1s,//speed
      scv1t,//temperature
      scv1v,//VIN
      scv2s,//speed
      scv2t,//temperature
      scv2v,//VIN
      scv3s,//speed
      scv3t,//temperature
      scv3v,//VIN
      scf1s,//speed
      scf1t,//temperature
      scf1v,//VIN
      scf2s,//speed
      scf2t,//temperature
      scf2v,//VIN
      scls,//speed
      sclt,//temperature
      sclv;//VIN
           
    int servo,
    u1,
    u2,
    u3;
   
    ADC *adcTemp;
    ADC *adcPress;
    
    volatile bool checkPending;
    
    bool imuControl;
};

#endif
